import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { RoleAvatar } from "../../avatar/RoleAvatar";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Cache } from "../../../cache/Cache";
import { BossFieldOrderData } from "../cellData/BossFieldOrderData";
import { Language } from "../../../../../extend/language/Language";
import { GameConst } from "../../../../component/gconst/GameConst";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { SBossFieldInfo } from "../../../../../Message/Public/SBossFieldInfo";
type int = number;
//class BossFieldStateCellRenderer
    
    export  class BossFieldStateCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            this.mouseChildren = true;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=new GTextFormat(FontUtil.songtiName, 12, ColorConfig.instance.getCampColor(1).intColor);
            this._tfCampNum1 = ObjCreate.createTextField("", 0, 9, 90, 20, this, loc1);
            var loc2=new GTextFormat(FontUtil.songtiName, 12, ColorConfig.instance.getCampColor(2).intColor);
            this._tfCampNum2 = ObjCreate.createTextField("", 76, 9, 90, 20, this, loc2);
            var loc3=new GTextFormat(FontUtil.songtiName, 12, ColorConfig.instance.getCampColor(3).intColor);
            this._tfCampNum3 = ObjCreate.createTextField("", 152, 9, 90, 20, this, loc3);
            this._tfBoss = ObjCreate.createTextField("", 240, 9, 90, 20, this, GlobalStyle.textFormatRed);
            this._btnState = ObjCreate.createGButton(this.TextComeIn, 80, 30, 56, 22, this);
            this._btnMonster = ObjCreate.createGButton(this.TextComeIn, 240, 30, 56, 22, this);
            this._bmpLine = ResouceConst.getScaleBitmap("SplitLine");
            this._bmpLine.x = 0;
            this._bmpLine.y = 58;
            this._bmpLine.width = 316;
            this._bmpLine.height = 2;
            this.addChild(this._bmpLine);
            this._btnState.drawNow();
            this._btnMonster.drawNow();
            this._btnState.addEventListener(flash.events.MouseEvent.CLICK, this.onComein);
            this._btnMonster.addEventListener(flash.events.MouseEvent.CLICK, this.onMonsterComeIn);
            return;
        }

        /* internal  */onComein(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.bossFieldInfo && this._btnState.label == this.TextComeIn) 
            {
                RoleAvatar.alertChangeMode(this.callBack);
            }
            return;
        }

        /* internal  */callBack(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.BossFieldRequestComein, {"fieldId": this.bossFieldInfo.fieldId, "force": Cache.instance.role.entityInfo.camp}));
            }
            return;
        }

        /* internal  */onMonsterComeIn(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.bossFieldInfo && this._btnState.label == this.TextComeIn) 
            {
                RoleAvatar.alertChangeMode(this.monsterCallBack);
            }
            return;
        }

        /* internal  */monsterCallBack(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.BossFieldRequestComein, {"fieldId": this.bossFieldInfo.fieldId, "force": 0}));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (typeof arg1 === "bossfieldorderdata") 
            {
                this.bossFieldInfo = (arg1 as BossFieldOrderData).bossFieldInfo;
                this._tfBoss.text = Language.getStringByParam(44701, this.bossFieldInfo.playerNumMap[0], GameConst.BossFieldBossForceMaxPlayerNum);
                this._tfCampNum1.text = GameDefConfig.instance.getECamp(1) + "（" + this.bossFieldInfo.playerNumMap[1] + "/" + GameConst.BossFieldCampForceMaxPlayerNum + "）";
                this._tfCampNum2.text = GameDefConfig.instance.getECamp(2) + "（" + this.bossFieldInfo.playerNumMap[2] + "/" + GameConst.BossFieldCampForceMaxPlayerNum + "）";
                this._tfCampNum3.text = GameDefConfig.instance.getECamp(3) + "（" + this.bossFieldInfo.playerNumMap[3] + "/" + GameConst.BossFieldCampForceMaxPlayerNum + "）";
            }
            return;
        }

        /* internal */ /* const */TextComeIn: string=Language.getString(41618);

        /* internal */ /* const */TextNotOpen: string=Language.getString(41619);

        /* internal */ /* var */_btnState: GButton;

        /* internal */ /* var */_btnMonster: GButton;

        /* internal */ /* var */_tfCampNum1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCampNum2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCampNum3: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfBoss: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpLine: ScaleBitmap;

        /* internal */ /* var */bossFieldInfo: SBossFieldInfo;
    }
